<%@page import="weaver.general.Util"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page import="com.alibaba.fastjson.*" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="java.sql.ResultSet" %>
<%
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json; charset=utf-8");
    JSONObject retObject = new JSONObject();
    retObject.put("code", 200);
    retObject.put("msg", "操作成功");
    try {
     	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // URL 参数
        Integer dateType = Integer.parseInt(request.getParameter("dateType"));
        JSONArray array = new JSONArray();
        if(dateType != null ){
            // 数据库查询
            String sql = "select * from vote_awards where is_del = 0 and date_type="+dateType +" ORDER BY ID DESC";
            RecordSet set = new RecordSet();
            set.executeSql(sql);
            Integer index = 0;
            while(set.next()){
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("id",Util.null2String(set.getInt("id")));                       	// 奖项配置id
                jsonObject.put("name",Util.null2String(set.getString("name")));                 	// 奖项配置名称
                String   startTime = Util.null2String(set.getString("start_time"));
	            jsonObject.put("startTime", Util.null2String(set.getString("start_time")));        	  						// 开始时间
				jsonObject.put("endTime",Util.null2String(set.getString("end_time")));        	  						// 开始时间
                jsonObject.put("dateType",Util.null2String(set.getString("date_type")));           	// 时间类型：1 年度 2 季度
                jsonObject.put("about",Util.null2String(set.getString("about")));           		//  
                jsonObject.put("regular",Util.null2String(set.getString("regular")));           	//  
                jsonObject.put("votes",Util.null2String(set.getString("votes")));           			//  
                jsonObject.put("votessame",Util.null2String(set.getString("votes_same")));           //  
                jsonObject.put("createTime",Util.null2String(set.getString("create_time"))); 
                array.add(jsonObject);
            }
        }
        retObject.put("data", array);
    } catch (Exception e) {
        e.printStackTrace();
        retObject.put("code", -1);
        retObject.put("msg", e.getMessage());
    } finally {
        PrintWriter printWriter = response.getWriter();
        printWriter.append(retObject.toJSONString());
    }
%>
 